package com.sh.data.engine.domain.datadev.flink.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sh.data.engine.common.enumDefinition.FlinkNodeTypeEnum;
import com.sh.data.engine.domain.datadev.flink.model.domain.FlinkNodeConfigDomain;
import com.sh.data.engine.domain.datadev.flink.model.domain.FlinkNodeConfigResourceDomain;
import com.sh.data.engine.domain.datadev.flink.model.domain.FlinkNodeFunctionDomain;
import com.sh.data.engine.domain.datadev.flink.model.domain.UploadFlinkResourceDomain;
import com.sh.data.engine.repository.dao.datadev.entity.FlinkNodeConfigEntity;

import java.util.List;
import java.util.Map;

/**
 * @author binghe.yxh
 */
public interface FlinkNodeConfigService extends IService<FlinkNodeConfigEntity> {

    UploadFlinkResourceDomain uploadFlinkResource(Long projectId, String fileName, byte[] data);

    boolean saveFlinkResource(FlinkNodeConfigResourceDomain saveResourceParam);

    List<FlinkNodeConfigDomain> getNodeConfigByNodeId(Long nodeId);

    FlinkNodeConfigDomain getNodeConfigById(Long id);

    FlinkNodeConfigResourceDomain getActiveFlinkResource(Long nodeId);

    IPage<FlinkNodeConfigResourceDomain> getFlinkResourcePage(
        Long nodeId, Integer pageNum, Integer pageSize);

    void deleteResourceById(Long id);

    void editFlinkResourceByNodeId(Long nodeId, String resourceName);

    void saveFunctionConfig(
        Long nodeId,
        Integer functionType,
        String className,
        Long resourceNodeId,
        String purpose,
        String format,
        String paramDesc,
        String userId,
        Long projectId);

    void insertOne(FlinkNodeConfigEntity flinkNodeConfigEntity);

    void updateOne(FlinkNodeConfigEntity flinkNodeConfigEntity);

    FlinkNodeFunctionDomain getFunctionDetail(Long nodeId);

    FlinkNodeConfigEntity getActiveByNodeId(Long nodeId);

    void deleteByNodeId(Long nodeId);

    List<FlinkNodeConfigEntity> getByNodeIds(List<Long> nodeIds);

    Map<Long, Integer> getScheduleTypeMapByIds(List<Long> ids);

    List<FlinkNodeConfigEntity> getActiveResourceByProjectId(Long projectId);

    FlinkNodeConfigEntity getActiveResourceByNodeId(Long nodeId);

    List<FlinkNodeConfigEntity> getRunnableTaskList(FlinkNodeTypeEnum flinkNodeTypeEnum);

    List<FlinkNodeConfigEntity> getAllTaskList(FlinkNodeTypeEnum flinkNodeTypeEnum);

    List<FlinkNodeConfigEntity> getStopedTaskList(FlinkNodeTypeEnum flinkNodeTypeEnum);

    IPage<FlinkNodeConfigEntity> getVersionsTaskList(FlinkNodeTypeEnum taskSql, Long nodeId, Integer pageNum, Integer pageSize);

    void rollbackVersion(FlinkNodeTypeEnum flinkNodeTypeEnum, Long nodeId, Long versionId);
}
